#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define mems(x,y) memset(x,y,sizeof x)
#define Mp make_pair
#define eb emplace_back
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define il inline
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a);i>=(b);i--)
#define go(i,u) for(int i=head[u];i;i=e[i].nxt)
	typedef long long ll;
	typedef pair<int,int> pii;
	template<typename T>
	il void read(T &x){
		int f=1;x=0;char c=gc();
		while(c<'0'||c>'9'){
			if(c=='-'){
				f=-1;
			}
			c=gc();
		}
		while(c>='0'&&c<='9'){
			x=x*10+c-48,c=gc();
		}
		x*=f;
	}
	template<typename T,typename ...Args>
	void read(T &x,Args &...args){
		read(x),read(args...);
	}
	template<typename T>
	il void write(T x){
		char buf[43];int len=0;
		if(x<0){
			pc('-'),x=-x;
		}
		do{
			buf[++len]=x%10,x/=10;
		}while(x);
		while(len){
			pc(buf[len--]+'0');
		}
	}
}
using namespace my_std;
const int N=1e6+7,M=-1,inf=0x3f3f3f3f,mod=0;
const ll INF=1ll*inf*inf;
int n=1e6,q;
multiset<int> st[2][N];
struct Tnode{
	int l,r,mn;
	Tnode(int _l=-inf,int _r=inf,int _mn=inf):
		l(_l),r(_r),mn(_mn){}
	Tnode operator+(const Tnode &rhs)const{
		return Tnode(max(l,rhs.l),min(r,rhs.r),min({mn,rhs.mn,rhs.r-l}));
	}
};
struct SGT{
	Tnode tr[N<<2];
	il void up(int u){
		tr[u]=tr[u<<1]+tr[u<<1|1];
	}
	void upd(int l,int r,int u,int x){
		if(l==r){
			int L=st[1][l].size()?*--st[1][l].end():-inf,R=st[0][l].size()?*st[0][l].begin():inf;
			tr[u]={L,R,R-L};
			return;
		}
		int mid=(l+r)>>1;
		if(x<=mid){
			upd(l,mid,u<<1,x);
		}else{
			upd(mid+1,r,u<<1|1,x);
		}
		up(u);
	}
}T;
void Yorushika(){
	read(q);
	multiset<int> L,R;
	while(q--){
		char op[3];scanf("%s",op);
		int x,y;read(x,y);
		if(op[0]=='A'){
			L.insert(x),R.insert(y);
			st[0][x].insert(y),st[1][y].insert(x);
		}else{
			L.erase(L.find(x)),R.erase(R.find(y));
			st[0][x].erase(st[0][x].find(y)),st[1][y].erase(st[1][y].find(x));
		}
		T.upd(1,n,1,x),T.upd(1,n,1,y);
		int nl=*--L.end(),nr=*R.begin();
		if(nl<nr){
			printf("%d\n",*st[0][nl].begin()-*--st[1][nr].end());
		}else{
			printf("%d\n",T.tr[1].mn);
		}
	}
}
signed main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	int t=1;
	//read(t);
	while(t--){
		Yorushika();
	}
}